Ext.define('ZYY.view.system.deptEdit', {
    extend: 'Ext.window.Window',
    alias : 'widget.deptEdit',
    requires: ['Ext.form.Panel'],
    layout: 'fit',
    autoShow: true,
    height: 200,
    width: 400,
    modal:true,
    initComponent: function() {
    	var comboxWithTree=Ext.create('Ext.form.field.Picker', {
    		name:"parentdept",
		    fieldLabel : '上级部门',
			anchor : '99%',
			labelAlign : 'right',
			labelWidth : 70,
			allowBlank : false,
			editable : false,
		    createPicker: function() {
		        return Ext.create('Ext.tree.Panel', {
		        	pickerField: this,//注意这里用法
		            hidden: true,
		            floating: true,
		            minHeight: 300,
		            store:'system.deptTree',
		            rootVisible:false,
				    listeners:{
		                        select: function(thisTree, record, index, obj ){
		                           this.pickerField.setValue(record.data.text);
		                           this.pickerField.collapse();
		                           this.pickerField.up('window').down("hiddenfield[name=pid]").setValue(record.data.id);
	                            },
	                            render:function(obj){
	                            	obj.expandAll();
	                            }
		           }
		        });
		    }
		});
        this.items = [
            {
                xtype: 'form',
                padding: '5 5 0 5',
                border: false,
                style: 'background-color: #fff;',
				defaults: {
		            anchor: '99%',
		            labelAlign : 'right',
					labelWidth : 70
		        },
                items: [
                    {
                        xtype: 'textfield',
                        name : 'deptname',
                        allowBlank : false,
                        vtype:"char",
                        fieldLabel: '部门名称'
                    },comboxWithTree,
                    {
                        xtype: 'textfield',
                        value: "0",
                        vtype:"int",
                        name : 'sortno',
                        
                        fieldLabel: '排序号'
                    },{
                     	 xtype: 'hiddenfield',
                     	 name : 'pid',
                     	 fieldLabel: 'pid'
                    },{
                     	 xtype: 'hiddenfield',
                     	 name : 'deptid',
                     	 fieldLabel: 'deptid'
                    }
                ]
            }
        ];

        this.buttons = [
            {
                text: '保存',
                action: 'save'
            },
            {
                text: '取消',
                scope: this,
                handler: this.close
            }
        ];

        this.callParent(arguments);
    }
});

